﻿using System.Collections.Generic;
using System.Collections.Specialized;

namespace MavlinkPacketViewer
{
    /// <summary>
    /// This is a poor man's observable collection, basically is is just a list
    /// which implements INPC, but only the 'reset' flavour of collection change
    /// notification. This is for better performance when binding to a grid, where
    /// updates are made in big chunks, and it is faster just to rebind the 
    /// grid to the collection periodically
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ResetableCollection<T> : List<T>, INotifyCollectionChanged
    {
        public event NotifyCollectionChangedEventHandler CollectionChanged;

        public void InvokeCollectionReset()
        {
            if (CollectionChanged != null)
            {
                CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            }

        }
    }
}